package org.mi.rabbitMQ.subscribe.client02;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.text.MessageFormat;

@Component
@Slf4j
public class Listener {
    /**
     * 监听消息队列
     * @param num
     */
    @RabbitListener(queues = "testSubscribe.client02")
    @RabbitHandler
    public void testSubscribe(Long num) {
        Thread thread = Thread.currentThread();
        log.debug("\n这是：{}\n线程ID：{}\n线程名称：{}\n监听队列为{}\n获得的数据为：{}","client02", thread.getId(), thread.getName(), "testSubscribe",num);
        System.out.println(MessageFormat.format("\n这是：{0}\n线程ID：{1}\n线程名称：{2}\n监听队列为{3}\n获得的数据为：{4}","client02", thread.getId(), thread.getName(), "testSubscribe",num));
    }
}
